package com.zyj.pojo;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name="t_category")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class Category {

	private Integer id;
	private String categoryname;
	private String categorymemo;
	private Category parent;
	private List<Category> children;
	private Integer assetid;
	private Room room;
	private List<Asset> assetList;
	
	
	@Id
	@GeneratedValue(strategy=IDENTITY)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getCategoryname() {
		return categoryname;
	}
	public void setCategoryname(String categoryname) {
		this.categoryname = categoryname;
	}
	public String getCategorymemo() {
		return categorymemo;
	}
	public void setCategorymemo(String categorymemo) {
		this.categorymemo = categorymemo;
	}
	@ManyToOne
	@JoinColumn(name="parentid")
	public Category getParent() {
		return parent;
	}
	public void setParent(Category parent) {
		this.parent = parent;
	}
	@OneToMany(fetch=FetchType.LAZY,mappedBy="parent")
	public List<Category> getChildren() {
		return children;
	}
	public void setChildren(List<Category> children) {
		this.children = children;
	}
	public Integer getAssetid() {
		return assetid;
	}
	public void setAssetid(Integer assetid) {
		this.assetid = assetid;
	}
	@ManyToOne
	@JoinColumn(name="roomid")
	public Room getRoom() {
		return room;
	}
	public void setRoom(Room room) {
		this.room = room;
	}
	@ManyToMany(targetEntity=com.zyj.pojo.Asset.class)
	@JoinTable(name="t_asset_category",joinColumns={@JoinColumn(name="categoryid")},
	inverseJoinColumns={@JoinColumn(name="assetid")})
	public List<Asset> getAssetList() {
		return assetList;
	}
	public void setAssetList(List<Asset> assetList) {
		this.assetList = assetList;
	}
}
